<?php
    $this->Html->scriptBlock($scriptSearchBox, array('inline' => false));
?>
<div class="title-body-content"><?php echo $title_for_layout; ?></div>
<div class="searchbox">
    <input type="text" id="search_text" name="sesearch_text" class="searchinput" value="<?php if($q !='all'){ echo $q; }?>" />
    <input type="button" id="search_button" value="Search" class="searchbutton" />
</div>
<div class="wrapper-table clearfix" id="<?php if($q !='all'){ echo 'highlight-plugin'; }?>">
    <table class="tbl-broking" border="1">
        <tr class="title-tbl" >
            <td class="td-file-att"><?php echo $this->Paginator->sort('risk_ref', 'Risk Reference #'); ?></td>
            <td class="td-inquirer"><?php echo $this->Paginator->sort('Producer'); ?></td>
            <td class="td-file-att"><?php echo $this->Paginator->sort('account_name','Account Name'); ?></td>
            <td class="td-file-att"><?php echo __('Period'); ?></td>
            <td class="td-file-att"><?php echo __('File Attached'); ?></td>
            <td class="td-action"><?php echo __('Actions'); ?></td>
        </tr>
        <?php
            foreach ($brokinginquiries AS $brokinginquiry) {
                $actions  = '<li>' . $this->Html->link(__('Edit'), array(
                    'controller' => 'brokinginquiries',
                    'action' => 'edit',
                    $brokinginquiry['Brokinginquiry']['id'],
                )) . '</li>';
                $actions .= ' ' . $this->Layout->adminRowActions($brokinginquiry['Brokinginquiry']['id']);
                $actions .= ' <li><div class="space3">|</div>' . $this->Html->link(__('Delete'), array(
                    'controller' => 'brokinginquiries',
                    'action' => 'delete',
                    $brokinginquiry['Brokinginquiry']['id'],
                    'token' => $this->params['_Token']['key'],
                ), null, __('Are you sure?')) . '</li>';

                $mimeType = explode('/', $brokinginquiry['Brokinginquiry']['mime_type']);
                $mimeType = $mimeType['0'];
                if ($mimeType == 'image') {
                    $thumbnail = $this->Html->link($this->Image->resize('/uploads/' . $brokinginquiry['Brokinginquiry']['attached'], 100, 200), array('controller' => 'brokinginquiries', 'action' => 'edit', $brokinginquiry['Brokinginquiry']['id']), array('escape' => false));
                } else {
                    $thumbnail = $this->Html->image('/img/icons/page_white.png') . ' ' . $brokinginquiry['Brokinginquiry']['mime_type'] . ' (' . $this->Filemanager->filename2ext($brokinginquiry['Brokinginquiry']['attached']) . ')';
                }

                echo '
                    <tr class="line-content-tbl" >
                        <td class="td-file-att" style="text-align:left; padding-left:5px;">' . $brokinginquiry['Brokinginquiry']['risk_ref'] . '</td>
                        <td class="td-inquirer" style="text-align:left; padding-left:5px;">' . $brokinginquiry['Inquirer']['name'] . '</td>
                        <td class="td-mime-type" style="text-align:left; padding-left:5px;">' . $brokinginquiry['Brokinginquiry']['account_name'] . '</td>
                        <td class="td-mime-type">' . date('m/d/Y', strtotime($brokinginquiry['Brokinginquiry']['date_from'])).' - '.date('m/d/Y', strtotime($brokinginquiry['Brokinginquiry']['date_to'])) . '</td>
                        <td class="td-file-att" style="text-align:left; padding-left:5px;">' . $this->Html->link(substr($brokinginquiry['Brokinginquiry']['path'], 9), $brokinginquiry['Brokinginquiry']['path']) . '</td>
                        <td class="td-action">
                            <ul>
                                ' . $actions . '
                            </ul>
                        </td>
                    </tr>';
            }
        ?>
    </table>
    <div class="wrapper-paging">
        <ul class="ul-paging">
            <?php echo $this->Paginator->numbers(array('tag'=>'li', 'separator' => '')); ?>
        </ul>
        <?php #echo $this->Paginator->counter(array('format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%'))); ?>
    </div>
    <div class="wrapper-button-form">
        <div class="button-form">
            <div class="button-aihre button-blue"><?php echo $this->Html->link(__('NEW'), array('action'=>'add')); ?></div>
        </div>
    </div>
</div>
<?php
$scriptHightlight = "
    $(function(){
        $('#highlight-plugin').removeHighlight().highlight('".$q."');
    });";
$this->Html->scriptBlock($scriptHightlight, array('inline' => false));
?>